package com.flame.shapeville.component.task1.shape2D;

import javafx.scene.paint.Color;
import javafx.scene.shape.Polygon;

/**
 * Represents a regular heptagon used in Task 1.
 * <p>
 * This class draws a seven-sided polygon with equal angles and side lengths.
 *
 * @author Flame Dev Team
 * @version 1.0
 * @since 2025-05-12
 */
public class JfHeptagon extends JfShape2D {

    /**
     * Constructs a new heptagon with the specified size.
     *
     * @param size the bounding box size for the heptagon
     */
    public JfHeptagon(double size) {
        this.size = size;
        // s = r + r * cos(360 / 14)
        double r = size / (1 + Math.cos(Math.toRadians((double) 360 / 14)));

        shape = new Polygon(
                size / 2, 0,
                size / 2 - r * Math.sin(Math.toRadians((double) 360 / 7)), r - r * Math.cos(Math.toRadians((double) 360 / 7)),
                size / 2 - r * Math.sin(Math.toRadians((double) 360 / 7 * 2)), r - r * Math.cos(Math.toRadians((double) 360 / 7 * 2)),
                size / 2 - r * Math.sin(Math.toRadians((double) 360 / 14)), size,
                size / 2 + r * Math.sin(Math.toRadians((double) 360 / 14)), size,
                size / 2 + r * Math.sin(Math.toRadians((double) 360 / 7 * 2)), r - r * Math.cos(Math.toRadians((double) 360 / 7 * 2)),
                size / 2 + r * Math.sin(Math.toRadians((double) 360 / 7)), r - r * Math.cos(Math.toRadians((double) 360 / 7))
        );
        initBaseParams(Color.CYAN);
    }
}
